package com.game.controller;

import com.game.pojo.vo.Result;
import com.game.tools.exception.CustomException;
import com.game.tools.exception.ExceptionEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@CrossOrigin
@RestController
@RequestMapping("/api")
@Api(tags = "其他")
public class OtherController {

    @GetMapping("/time")
    @ApiOperation("获取系统时间")
    public Result getTime(){
        LocalDateTime localDateTime = LocalDateTime.now();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        //throw new CustomException(ExceptionEnum.UNKNOWN_ERROR, "getTime");
        return new Result(200,"请求成功",dateTimeFormatter.format(localDateTime));
    }
}
